package com.huobao.yunying.adapters;

import com.huobao.yunying.entity.ProgectManager;
import com.huobao.yunying.utils.ImageUtils;
import com.huobao.yunying.utils.SkipUtils;
import com.huobao.zhangying.R;

import android.content.Context;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.CompoundButton.OnCheckedChangeListener;
import android.widget.ImageView;
import joanzapata.android.BaseAdapterHelper;
import joanzapata.android.QuickAdapter;

public class Adapter_Progect_Manager extends QuickAdapter<ProgectManager> {

	public Adapter_Progect_Manager(Context context) {
		super(context, R.layout.item_progect_manager);
	}

	@Override
	protected void convert(BaseAdapterHelper arg0, final ProgectManager arg1) {
		ImageView imageView = arg0.getView(R.id.imageview);
		ImageUtils.loadimg(imageView, arg1.default_image);
		arg0.setText(R.id.tv_name, arg1.goods_name).setText(R.id.tv_price, arg1.price).setText(R.id.tv_content, "");
		CheckBox box = arg0.getView(R.id.checkbox);
		box.setChecked(arg1.isChecked);
		box.setOnCheckedChangeListener(new OnCheckedChangeListener() {
			
			@Override
			public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
				arg1.isChecked = isChecked;
				notifyDataSetChanged();
			}
		});
		imageView.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				SkipUtils.seeDetail(context, arg1.goods_id, arg1.default_image);
			}
		});
	}

}
